/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package titanisu.basicMathModule1.divisibility39;

import java.util.ArrayList;
import java.util.Random;
import titanisu.mathUtil.NumberFetcher;

/**
 *
 * @author Balaji
 */
public class QuestionGeneratorAddSub {

    ArrayList quest = new ArrayList();
    boolean intQ = false;

    private void setQ(ArrayList arlst) {
        this.quest = arlst;
    }

    public ArrayList getQuest() {
        return quest;
    }

    public void setQuest(ArrayList quest) {
        this.quest = quest;
    }

    /*
     * Generates a single question in below format is forms and array with question and nominator and denominator
     * The final the arraylist is put in variable quest and this methog returns a string putting forward only question
     * quest.get(0) question string
     * quest.get(1) answer nominator
     * quest.get(0) answer denominator
     * 
     * @param: void
     * @returns : String having question
     */
    public String getQuestions() {
        NumberFetcher nf = new NumberFetcher();

        ArrayList al = new ArrayList();
        al.add(3);
        al.add(9);
        int v = (Integer) al.get(new Random().nextInt(al.size()));
        int x = nf.getPrime(500, 999) * v;

        quest.add(0, "" + x);
        quest.add(1, "" + v);
        setQ(quest);
        System.out.println(" the quest is " + quest);
        return (String) quest.get(0);
    }

    /**
     * Gives the answers
     *
     * @return
     */
    public String getAnswer() {
        String answer = "";
        String den = (String) quest.get(1);
        return answer;
    }

    void setIntegers(boolean b) {
        intQ = b;
        System.out.println("intQ = " + intQ);
    }
}
